package com.ruoyi.business.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.service.ISysDeptService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 内容:
 * 作者: cy
 */
@RestController
@RequestMapping("business/dept")
public class DeptController extends BaseController {

    @Autowired
    private ISysDeptService iSysDeptService;

    // 写一个返回部门集合的方法即可

    /**
     * 多租户的系统
     * 管理来查询
     *
     * @return
     */
    @GetMapping("list")
    @ApiOperation("查询部门集合")
    public AjaxResult loadDepts() {
        // 获取当前用户
        LoginUser loginUser = getLoginUser();
        // 查询部门集合
        List<SysDept> sysDepts = iSysDeptService.selectDeptsByLoginUser(loginUser);
        return AjaxResult.success(sysDepts);
    }

}
